#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Error(int type)
{
    switch (type) {
    case 0:
        printf("符号1的数量少于2");
        break;
    case 1:
        printf("出现非01字符");
        break;
    case 2:
        printf("符号1的数量大于2");
    }
}
int judge1(char* str)
{
    char ch = str[0];
    int state = 0, index = 0, type;
    while (ch == '0')
        ch = str[index++];
    // 进入状态1
    if (ch == '1') {
        state == 1;
        ch = str[index++];
        while (ch == '0')
            ch = str[index++];
        // 进入状态2（终止态）
        if (ch == '1') {
            state = 2;
            ch = str[index++];
            while (ch == '0')
                ch = str[index++];
            if (ch == '#') {
                printf("字符串通过");
                return 1;
            } else if (ch == '1')
                type = 2;
            else
                type = 1;
            Error(type);
        } else {
            if (ch == '#')
                type = 0;
            else
                type = 1;
            Error(type);
        }
    } else {
        if (ch == '#' || ch == '1')
            type = 0;
        else
            type = 1;
        Error(type);
    }
    return 0;
}
int judge2(char* str)
{
    int change[3][2] = { { 0, 1 }, { 1, 2 }, { 2, -1 } };
    int i, state = 0, k;
    for (i = 0; i < strlen(str) - 1; i++) {
        k = str[i] - '0';
        if (k == 0 || k == 1) {
            state = change[state][k];
        } else {
            Error(1);
            return 0;
        }
        if (state == -1) {
            Error(2);
            return 0;
        }
    }
    if (state == 2) {
        printf("字符串通过");
        return 1;
    } else if (state == 0 || state == 1)
        Error(0);
    return 0;
}
int judge3(char* str)
{
    int state = 'a', i, type;
    for (i = 0; i < strlen(str); i++) {
        switch (state) {
        case 'a':
            if (str[i] == '0')
                state = 'a';
            else if (str[i] == '1')
                state = 'b';
            else {
                Error(1);
                return 0;
            };
            break;
        case 'b':
            if (str[i] == '0')
                state = 'b';
            else if (str[i] == '1')
                state = 'c';
            else {
                if (str[i] == '#') {
                    type = 0;
                } else
                    type = 1;
                Error(type);
                return 0;
            }
            break;

        case 'c':
            if (str[i] == '0')
                state = 'c';
            else {
                if (str[i] == '1')
                    type = 2;
                else if (str[i] == '#') {
                    printf("字符串通过");
                    return 1;
                } else
                    type = 1;
                Error(type);
                return 0;
            }
            break;
        }
    }
}
int main()
{
    // char str[]="0101#";
    char str[100];
    scanf("%s", str);
    int result = judge3(str);
    // printf("\nresult:%d\n", result);
    system("pause");
    return 0;
}